<template>
	<view class="scan-content">
		<view v-if="isshixiao!=1">
			<image src="../../static/u7.png" class="scan-img"></image>
			<view class="tips-text1">采招网账号电脑端登录确认</view>
			<view class="tips-text2">为确保账户安全，请确认是您本人操作</view>
			<view class="confirm-btn" @click="queren">确认登录电脑端</view>
			<view class="cancel-btn" @click="quxiao">取消登录</view>
		</view>
		<view v-else>
			<image src="../../static/u7.png" class="scan-img"></image>
			<view class="tips-text3">二维码失效了，先刷新二维码再试试吧</view>
			<view class="confirm-btn" @click="quxiao">重新扫码</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				result: '',
				scantype: '',
				isshixiao: 0
			};
		},
		onLoad(options) {
			if (options.result) {
				this.result = options.result;
				this.scantype = options.scantype;
				this.isshixiao = options.isshixiao;
			}
			console.log(this.result, this.scantype, this.isshixiao);
		},
		methods: {
			queren() {
				if (this.result && this.scantype) {
					let data = this.initNewData();
					data.from = 4038;
					data.result = this.result;
					data.apptoken = data.token;
					data.scantype = this.scantype;
					data.location = 6470;
					uni.request({
						//url: 'http://192.168.1.221:8077/JsonHandler/SaomaDenglu_app.aspx', //检查更新的服务器地址
						url: 'https://sso.bidcenter.com.cn/JsonHandler/SaomaDenglu_app.aspx', //检查更新的服务器地址
						data: data,
						method: "POST",
						header: {
							"content-type": "application/x-www-form-urlencoded" //"application/json"
						},
						success: (res) => {
							if (res.statusCode == 200) {
								if (!res.data.ret) {
									if (res.data.msg)
										uni.showToast({
											title: res
												.data
												.msg,
											icon: "none"
										});
									return;
								} else {
									//成功
									if (res.data.msg) {
										uni.showToast({
											title: res
												.data
												.msg,
											icon: "none",
											duration: 1000,
											success: function() {
												setTimeout(function() {
													uni.navigateBack({
														delta: 1
													})
												}, 1000)
											}
										});
									} else {
										uni.navigateBack({
											delta: 1
										})
									}
								}
							} else {
								uni.showToast({
									title: '二维码验证失败！',
									icon: "none"
								});
							}
						},
						fail: (res) => {
							uni.showToast({
								title: '二维码验证出错！',
								icon: "none"
							});
						}
					})
				} else {
					uni.showToast({
						title: '获取参数失败，请联系客服！',
						icon: "none"
					});
				}
			},
			quxiao() {
				uni.navigateBack({
					delta: 1
				});
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f8f8f8;
	}

	.scan-content {
		display: flex;
		align-items: center;
		flex-direction: column;
		justify-content: center;
		padding-top: 150rpx;

	}

	.scan-img {
		width: 665rpx;
		height: 271rpx;
		margin-bottom: 100rpx;
	}

	.tips-text1 {
		color: #000;
		font-size: 40rpx;
		margin-bottom: 30rpx;
		text-align: center;
		font-weight: 700;

	}

	.tips-text3 {
		color: #FF0000;
		font-size: 35rpx;
		margin-bottom: 100rpx;
		text-align: center;
	}

	.tips-text2 {
		font-size: 30rpx;
		color: #000;
		text-align: center;
	}

	.confirm-btn {
		height: 90rpx;
		line-height: 90rpx;
		border-radius: 100px;
		background-color: #ff4a00;
		color: #FFFFFF;
		font-size: 32rpx;
		width: 100%;
		text-align: center;
		margin: 100rpx 0 30rpx;
	}

	.cancel-btn {
		height: 90rpx;
		line-height: 90rpx;
		border-radius: 100px;
		border: 1px solid #aaaaaa;
		background-color: #FFFFFF;
		color: #555555;
		font-size: 32rpx;
		width: 100%;
		text-align: center;
	}
</style>
